package com.wedata.抖音;

import cn.hutool.json.JSONObject;
import com.wedata.HttpUtils;

/**
 * 抖音接口下线通知
 * https://developer.open-douyin.com/announcement/289
 */
public class 抖音视频 {

    static String douYinHost = "https://open.douyin.com";

    public static void main(String[] args) {
        StringBuffer param = new StringBuffer(douYinHost);
        param.append("/api/douyin/v1/video/video_list");
        param.append("?open_id=").append("7ab53ade-18d0-4f48-8569-98ef6c5ac8ec");
        param.append("&access_token=").append("act.eab7efe63abdcf501787efd1b5e16853d7sMnQeEbtXVEYQIc0wTEsQ9zkL1_lq");
        param.append("&cursor=").append(0);
        param.append("&count=").append(20);

        JSONObject result = HttpUtils.doGet(param.toString());
        //{"data":{"description":"该能力API已下线，不再支持调用","error_code":28001056},"extra":{"sub_error_code":0,"sub_description":"该能力API已下线，不再支持调用","description":"该能力API已下线，不再支持调用","now":1742804435100,"error_code":28001056,"logid":"2025032416203521CDB190EE02AE0180C1"}}
        System.out.println(result);
    }

    public static void 获取抖音明细数据() {
        //获取个人授权token
        //select access_token from weapp_douyin_auth where dy_uid = 11;
        //获取个人openid
        //select open_id from weapp_user_douyin where id=11;
        String url = douYinHost + "/api/douyin/v1/video/video_data";
        String param = "?open_id=7ab53ade-18d0-4f48-8569-98ef6c5ac8ec&access_token=act.eab7efe63abdcf501787efd1b5e16853d7sMnQeEbtXVEYQIc0wTEsQ9zkL1_lq";

        JSONObject header = new JSONObject();
        JSONObject body = new JSONObject();
        body.set("item_ids",new String[]{"@9VwRxvrECc5nZi6nZ91sGc790WHqOv2DO5RxoQqjLFMTZ/j460zdRmYqig357zEBpmY/1lJS7UeQX3uBX4P6Hg==",
                "@9VwRxvrECc5nZi6nZ91sGc790WHtPPqCOJd2oQKlLFYUZ/L560zdRmYqig357zEBaGH/0aIaNw3DslC3b5XrFA==",
                "@9VwRxvrECc5nZi6nZ91sGc790WHtPfuCOJN1rw6hL1QTa/X060zdRmYqig357zEB1t340ztOVmDe9kA+mXoTDQ==",
                "@9VwRxvrECc5nZi6nZ91sGc790WHtNf2FOp1zqg+mLVkSZ/j160zdRmYqig357zEB++k5ND+XOFL+pV/cXDMqHA==",
                "@9VwRxvrECc5nZi6nZ91sGc790WHsOP+APZV4oA+jLlkUZ/f060zdRmYqig357zEB/BKv00pjty0AmUunc/D/tQ==",
                "@9VwRxvrECc5nZi6nZ91sGc790WHvPvyLPZxwrA6kJlAVbff960zdRmYqig357zEBMwTt41tB93zLlLTwpW9g/w==",
                "@9VwRxvrECc5nZi6nZ91sGc790WHvOvqAOZV0oAikLVAUbPf660zdRmYqig357zEBWroOZNDUqMJilCZF2oVbFA==",
                "@9VwRxvrECc5nZi6nZ91sGc790WHuPfCGOZV3qgqjK1ITZvP+60zdRmYqig357zEBvm5J8hHM7q9C8lFrE1RsMg==",
                "@9VwRxvrECc5nZi6nZ91sGc790WHuOfqAOZR1rQ+gL1IVaPL560zdRmYqig357zEBXJYovhwHlHUB3GpVRBliCA==",
                "@9VwRxvrECc5nZi6nZ91sGc790WHuNfuKOJBxqQqhJlITb/X160zdRmYqig357zEBv8QGaPoMLVE6z/G8WK0WiQ==",
                "@9VwRxvrECc5nZi6nZ91sGc790WHuNfuBOZJ0rAquLFUVb/P960zdRmYqig357zEBkj5qgNA/6nAFkjdWY4rq4g=="
        });
        JSONObject result = HttpUtils.sendPost(url+param, header, body);

        System.out.println(result);
    }
}
